Dark is a simple example of what I call a "Blackout" program. It is a Multifinder "Aware" program which, for fairly obvious reasons, will only run as a foreground task. Dark is usually launched by Darkness to darken the screen. When it starts, Dark creates a window the size of the screen and paints it black. The program runs until the user moves the mouse or does anything to cause an event, e.g. mouse click, key press, etc.
So why am I reading this?
The Darkness screen saver allows the user to create programs (I call them "Blackouts"), more interesting than Dark, which will be used to blacken the screen. This is more fun than always watching Pyro™ fireworks or the Moire pattern. This idea is also used by another screen saver, AfterDark™, but the "Blackouts" for Darkness are stand-alone program, so they are much easier to write than modules for AfterDark™.
What do I need?
Dark was written in THINK C 4.0, but it is fully compatible with 3.0. The source code should compile in MPW C with only a few changes. The actual Blackouts can be written in any language since they are stand-alone applications. Some friends of mine at Apple have written Blackouts using MPW C and their source code can be found in another archive.
Even if you are not a Mac hacker, the information in Inside Macintosh volume 1 and some time is all you need to write a fun Blackout.
What are all these files?
Included in the archive are the following files:
Darkness: the screen saver application
Dark: the default Blackout
dark.c: the main segment of the source code (well documented)
darkInit.c: the initialization routines of the Dark Blackout
dark π.rsrc: the resources for Dark (actually just one menu)
Darkness_docs.mw: the documentation to Darkness
Dark_docs.mw: you are reading this file now
Some advanced notes on Dark:
- Dark has its file type set to "Dark" instead of "APPL" so that it can't be launched. Double clicking on Dark will launch Darkness if it is not running or put up an error message if Darkness is running. Making your Blackout a "Dark" file will also give it the same icon as Dark.
- The main event loop of Dark is sent a null event at least twice a second, every 30 ticks. If your Blackout needs to be called more often, change the second to last parameter to WaitNextEvent (default is 30L).
- The shell program for Dark should not be used as a basis for other Multifinder utilities. Too much of the basic code is not included. It can be used to learn how to handle the new osEvt events.
About the Author:
Lunarmobiscuit, affectionately "Luni" for short, is currently a Junior Math/CS major at Carnegie Mellon University in Pittsburgh, Pennsylvania. He is the author of _Launch, another Shareware Multifinder utility, and a bunch of other programs which he keeps to himself.
The Lunarmobiscuit programming philosophy can be summed up in three ideas, "Make it small, fast, and stable." Luni hates programs such as Word or the infamous FullWrite™ which contain every feature imaginable and which break all three of his programming rules. This explains why Dark doesn't have any fancy graphics.
About the Shareware System:
No one would seriously go to a computer store, pick up the latest copy of Darkness, look at the $39.99 price tag, and buy the program. There is also no way that I would put up with a publisher, distributor, etc. Therefore, to make promote the greatest happiness I am offering Darkness through the Shareware, a.k.a. Honor, system. Make as many copies as you wish and distribute it to all your friends. If you use the program, please write a check for $10 made out to Michael Libes and send it to:
Michael Libes
1071 Morewood Avenue
Pittsburgh, PA 15213
I also encourage everyone to write his own Blackouts and send them along with your contribution.
Acknowledgments:
Many thanks to Tom Dowdy at Apple for his knowledge, ideas, and sample Blackouts.
I must also thank all those who subscribe to netnews.comp.sys.mac.programmers since their knowledge saved me many days of work.